<%--
  Created by IntelliJ IDEA.
  User: asus
  Date: 2023/5/5
  Time: 8:11
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Login</title>
    <script src="js/vue.js"></script>
    <style>
        #act{
            display: none;
        }
    </style>
</head>
<body>
<%--${pageContext.request.contextPath}/employee?things=login--%>
<div id="app">
    <form :action="action">
        账号: <input type="text" name="ename" v-model="ename"><br>
        密码: <input type="password" name="epsd" v-model="epsd"><br>
        <input type="text" name="act" value="login" id="act">
        <button @click="submits">登录</button>
    </form>
    <button onclick="window.location.href='${pageContext.request.contextPath}/register.jsp'">注册</button>
</div>
</body>
<script>
    Vue.config.productionTip = false;

    const vm = new Vue({
        el:'#app',
        data:{
            action:"",
            ename:"",
            epsd:""
        },
        methods:{
            submits(){
                if(this.ename!=""&&this.epsd!=""){
                    this.action="${pageContext.request.contextPath}/employee"
                }else{
                    alert("账号密码不能为空,请重新输入!")
                }
            }
        }
    })
    
    const flag = '<%=request.getParameter("flag")%>';
    if(flag=="false"){
        alert("登录失败,请重新输入账号密码!");
    }
</script>
</html>
